#pragma once

#include "BaseWindow.h"
#include "Theme.h"

class CBufferedWnd : public CBaseWindow
{
public:
  CBufferedWnd()
  {}

public:
  virtual void Draw(CDCHandle dc, const CRect& rClip)
  {
    dc.FillRect(rClip, GetWndClassInfo().m_wc.hbrBackground);
  }

public:
// Message map and handlers
	BEGIN_MSG_MAP(CBufferedWnd)
		CHAIN_MSG_MAP(CBaseWindow)
	END_MSG_MAP()

protected:
// Overrideables
	virtual void DoPaint(CDCHandle dc, const CRect& rClip)
  {
    Draw(s_backbuf.m_hDC, rClip);

    if (s_backbuf.m_hDC != dc.m_hDC)
    {
      dc.BitBlt(rClip.left, rClip.top, rClip.Width(), rClip.Height(),
                s_backbuf, rClip.left, rClip.top, SRCCOPY);
    }
  }

protected:
  static CScreenDC s_backbuf;
};